<template>
	<view class="">
		<view class="m2432">
			<view class="flex_btw">
				<view class="fw600 fs32 c2a7">基础信息</view>
				<view class="eitd fw500 fs28" @click="getEitd">修改</view>
			</view>
			<view class="mt24 p24 bgf br12">
				<view class="flex_x mb24">
					<view class="c3 fw500 fs28 w120">门店名称</view>
					<view class="ml50 flex1 ipt flex_x plr20">
						<u--input placeholder="请输入内容" inputAlign='center' clearable border="none"
							v-model="shop_details.title">
						</u--input>
					</view>
				</view>
				<view class="flex_x mb24">
					<view class="c3 fw500 fs28 w120">联系人</view>
					<view class="ml50 flex1 ipt flex_x plr20">
						<u--input placeholder="请输入内容" inputAlign='center' clearable border="none"
							v-model="shop_details.name">
						</u--input>
					</view>
				</view>
				<view class="flex_x mb24">
					<view class="c3 fw500 fs28 w120">联系方式</view>
					<view class="ml50 flex1 ipt flex_x plr20">
						<u--input placeholder="请输入内容" inputAlign='center' clearable border="none"
							v-model="shop_details.mobile">
						</u--input>
					</view>
				</view>
				<view class="flex_x">
					<view class="c3 fw500 fs28 w120">营业时间</view>
					<view class="ml50 flex1 ipt flex_x plr20">
						<u--input placeholder="请输入内容" inputAlign='center' clearable border="none"
							v-model="shop_details.workrange">
						</u--input>
					</view>
				</view>
			</view>


			<view class="mt40">
				<view class="fw600 fs32 c2a7">地址信息</view>
			</view>
			<view class="mt24 p24 bgf br12">
				<view class="flex_x mb24">
					<view class="c3 fw500 fs28 w120">门店地址</view>
					<view class="ml50 flex1 ipt flex_x plr20" @click="selectCity">
						<u--input disabled disabledColor='#F4F4F4' placeholder="请输入内容" inputAlign='center' clearable
							border="none" v-model="shop_details.address">
						</u--input>
					</view>
				</view>
				<view class="flex_x mb24">
					<view class="c3 fw500 fs28 w120">详细地址</view>
					<view class="ml50 flex1 ipt flex_x plr20">
						<u--input placeholder="请输入内容" inputAlign='center' clearable border="none"
							v-model="shop_details.detailed">
						</u--input>
					</view>
				</view>
			</view>
		</view>
		<view class="">
			<hintPopup :show.sync="show" hint='确认修改' title='你确认要修改店铺信息吗？' color="#2A71C0" @confirm='confirm'>
			</hintPopup>
			<hintBox :show.sync="hintShow" title='提交成功' color='#2A71C0' :time='1500'></hintBox>
		</view>

	</view>
</template>

<script>
	import tool from '../../../../utils/tool/tool.js'
	export default {
		components: {},
		data() {
			return {
				shop_details: { //店铺信息
					title: '', //门店名
					name: '', //联系人
					mobile: '', //联系方式
					workrange: '', //营业时间
					address: '', //门店地址
					detailed: '', //详细地址
					lng: '', //经度
					lat: '', //纬度
				},

				show: false, //确认弹窗
				hintShow: false, //完成提示框
			}
		},
		onLoad() {
			this.shopIndex()
		},
		onShow() {

		},
		methods: {
			shopIndex() { //首页数据 公告内容
				this.$api.shopIndex().then(res => {
					if (res.code == 1) {
						this.shop_details = tool.objAssign(this.shop_details, res.data)
					}
				})
			},
			selectCity() { //选择地址
				uni.chooseLocation({ //选择地址
					success: (res) => {
						// console.log(res);
						this.shop_details.address = res.address
						this.shop_details.lng = res.address
						this.shop_details.lat = res.longitude
					}
				})
			},
			getEitd() { //修改按钮
				if (!this.shop_details.title) {
					uni.$u.toast('请输入门店名称')
				} else if (!this.shop_details.name) {
					uni.$u.toast('请输入联系人')
				} else if (!this.shop_details.mobile) {
					uni.$u.toast('请输入联系方式')
				} else if (!this.shop_details.workrange) {
					uni.$u.toast('请输入营业时间')
				} else if (!this.shop_details.address) {
					uni.$u.toast('请输入选择门店地址')
				} else if (!this.shop_details.detailed) {
					uni.$u.toast('请输入详细地址')
				} else {
					this.show = true
				}
			},
			confirm() { //确定
				uni.$u.debounce(this.shopEdit, 500) //防抖
			},
			shopEdit() { //修改接口
				this.$api.shopEdit(this.shop_details).then(res => {
					if (res.code == 1) {
						this.show = false
						this.hintShow = true
						setTimeout(() => {
							uni.navigateBack()
							uni.$emit('refresh', true)
						}, 1500)
					} else {
						this.show = false
					}
					uni.$u.toast(res.msg)

				})
			},
		},
		computed: {

		},
		watch: {

		}
	}
</script>

<style lang="scss" scoped>
	.eitd {
		color: #FF8C0A;
	}

	.ipt {
		height: 84upx;
		background: #F4F4F4;
		border-radius: 12upx;
	}
</style>
